<%@ page language="java" pageEncoding="UTF-8"%>
<%@ include file="/base.jsp"%>
<%@ include file="/module/taglibs.jsp"%>
<%@ include file="/module/nocache.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>项目管理</title>
<%@ include file="/module/js.jsp"%>
<script type="text/javascript">
$(document)
.ready(
		function() {
			$('#dg').datagrid({
			 /*queryParams : {semid: $('#semid').val()},
			 onSortColumn :function(sort,order){
			   var _sort=sort;
			   var _order=order;
			   var options=$('#dg').datagrid('getPager').data("pagination").options;
			   var page=options.pageNumber;
			   var pageSize=options.pageSize;
			   //alert(page+"==="+pageSize);
			   window.setTimeout(function(){
				   $.post("${basePath}/semesterSummary/semesterSummaryList",{orderFlag:_order,orderField:_sort,semid: $('#semid').val()},
							function(data){
							  $('#dg').datagrid("loadData",data); 
						   });
						   },100);  
			   },*/
			   rowStyler: function(index,row){
			   }
			});
			
			//查询
			$('#btnQuery').click(function() {
			  $('#dg').datagrid('load',{
				  semid: $('#semid').val()
			  });
			});
			//新增
			$('#btnAdd').click(function() {
			  document.semesterForm.action = "${basePath}/semesterSummary/addSemesterSummaryForward";
			  document.semesterForm.submit();
			});
			
			//删除
			$('#btnDelete').click(function() {
			    $("#idList").val("");
			    var count = 0;		
				var idList = new Array();
			    var sels = $("#dg").datagrid("getSelections");
			    for(var i in sels){
				   idList.push(sels[i].zjid);
					count++;
			    }
			  if (count == 0) {
				layer.alert("您至少选择一条删除记录信息", {icon: 3});
				return false;
				}else{
					  layer.confirm("您是否删除当前选中数据信息", {icon: 3, title:'提示',skin:'layer-ext-moon'}, function(index){
						    $("#idList").val(idList);
						    document.semesterForm.action = "${basePath}/semesterSummary/removeSemesterSummary";
							document.semesterForm.submit();
					  },function(index){
							layer.close(index);
					  });
				}
			});
		});

/**
 * 添加超链接
 * @param value
 * @param row
 * @param index
 * @returns {String}
 */
function formaterLink(value, row, index) {
    return "<a href='${basePath}/semesterSummary/modiftySemesterSummaryForward?zjid=" + row.zjid + "'>" + value + "</a>";
} 
//  function pagerFilter(data){
// 		if (typeof data.length == 'number' && typeof data.splice == 'function'){	// is array
// 			data = {
// 				total: data.length,
// 				rows: data
// 			}
// 		}
// 		var dg = $(this);
// 		var opts = dg.datagrid('options');
// 		var pager = dg.datagrid('getPager');
// 		pager.pagination({
// 			onSelectPage:function(pageNum, pageSize){
// 				opts.pageNumber = pageNum;
// 				opts.pageSize = pageSize;
// 				pager.pagination('refresh',{
// 					pageNumber:pageNum,
// 					pageSize:pageSize
// 				});
// 				dg.datagrid('loadData',data);
// 			}
// 		});
// 		if (!data.originalRows){
// 			data.originalRows = (data.rows);
// 		}
// 		var start = (opts.pageNumber-1)*parseInt(opts.pageSize);
// 		var end = start + parseInt(opts.pageSize);
// 		data.rows = (data.originalRows.slice(start, end));
// 		return data;
// 	}
</script>


</head>
<body>
	<form action="#" name="semesterForm" id="semesterForm" method="post">
	  <input type="hidden" id="idList" name="idList" value=""/>
		<table cellpadding="1" cellspacing="1" border="0">
			<tr>
				<td><input type="button" id="btnQuery" autocomplete="off"  value="查询"
					class="inputButton" /></td>
				<td><input type="button" id="btnAdd" autocomplete="off"  value="添 加"
					class="inputButton" /></td>
				<td><input type="button" id="btnDelete" autocomplete="off"  value="删除"
					 class="inputButton"/></td>
			</tr>
		</table>
		<table cellpadding="1" cellspacing="1">
			<tr>
				<td>学期：</td>
				<td>
				<select id="semid" name="semid" class="selectList2">
				 <option value="">全部</option>
				 <c:forEach items="${semesterList}" var="semester">
				 <option value="${semester.xqid}">${semester.xqmc}</option>
				 </c:forEach>
				</select>
			</td>
			</tr>
		</table>
		<br/>
     <table id="dg"  style="width: 73%"
		data-options="pagination:true,collapsible:true,url:'${basePath}/semesterSummary/semesterSummaryList',method:'post',remoteSort:true,striped:true">
		<thead>
			<tr>
				<th data-options="field:'zjid',checkbox:true,width:100,align:'center'"></th>
				<th data-options="field:'xqmc',sortable:true,nowrap:true,width:200,align:'center',formatter:formaterLink">学期</th>
				<th data-options="field:'hdry',nowrap:true,width:300,align:'center',sortable:true">本学期取得的荣誉</th>
				<th data-options="field:'sqxm',nowrap:true,width:300,align:'center',sortable:true">本学期申请的先进项目</th>
				<th data-options="field:'createtime',nowrap:true,width:200,align:'center',sortable:true,formatter:formatDate">登记时间</th>
			</tr>
		</thead>
	</table>
		<script type="text/javascript">
			 if("${msg}"!=""){
			       layer.alert("${msg}", {icon: 6});
			  } 
			 compareListValue(document.getElementById('semid'),'${semester.xqid}');
			 
		</script>
	</form>
</body>
</html>
